package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.IflightOrderInvoice;
import com.ktgj.flight.service.IIflightOrderInvoiceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 国际机票订单发票信息Controller
 * 
 * @author ruoyi
 * @date 2022-05-31
 */
@RestController
@RequestMapping("/invoice")
public class IflightOrderInvoiceController extends BaseController
{
    @Autowired
    private IIflightOrderInvoiceService iflightOrderInvoiceService;

    /**
     * 查询国际机票订单发票信息列表
     */
    @PreAuthorize(hasPermi = "system:invoice:list")
    @GetMapping("/list")
    public TableDataInfo list(IflightOrderInvoice iflightOrderInvoice)
    {
        startPage();
        List<IflightOrderInvoice> list = iflightOrderInvoiceService.selectIflightOrderInvoiceList(iflightOrderInvoice);
        return getDataTable(list);
    }

    /**
     * 导出国际机票订单发票信息列表
     */
    @PreAuthorize(hasPermi = "system:invoice:export")
    @Log(title = "国际机票订单发票信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IflightOrderInvoice iflightOrderInvoice) throws IOException
    {
        List<IflightOrderInvoice> list = iflightOrderInvoiceService.selectIflightOrderInvoiceList(iflightOrderInvoice);
        ExcelUtil<IflightOrderInvoice> util = new ExcelUtil<IflightOrderInvoice>(IflightOrderInvoice.class);
        util.exportExcel(response, list, "国际机票订单发票信息数据");
    }

    /**
     * 获取国际机票订单发票信息详细信息
     */
    @PreAuthorize(hasPermi = "system:invoice:query")
    @GetMapping(value = "/{iflightOrderInvoiceId}")
    public AjaxResult getInfo(@PathVariable("iflightOrderInvoiceId") Long iflightOrderInvoiceId)
    {
        return AjaxResult.success(iflightOrderInvoiceService.selectIflightOrderInvoiceById(iflightOrderInvoiceId));
    }

    /**
     * 新增国际机票订单发票信息
     */
    @PreAuthorize(hasPermi = "system:invoice:add")
    @Log(title = "国际机票订单发票信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IflightOrderInvoice iflightOrderInvoice)
    {
        return toAjax(iflightOrderInvoiceService.insertIflightOrderInvoice(iflightOrderInvoice));
    }

    /**
     * 修改国际机票订单发票信息
     */
    @PreAuthorize(hasPermi = "system:invoice:edit")
    @Log(title = "国际机票订单发票信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IflightOrderInvoice iflightOrderInvoice)
    {
        return toAjax(iflightOrderInvoiceService.updateIflightOrderInvoice(iflightOrderInvoice));
    }

    /**
     * 删除国际机票订单发票信息
     */
    @PreAuthorize(hasPermi = "system:invoice:remove")
    @Log(title = "国际机票订单发票信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iflightOrderInvoiceIds}")
    public AjaxResult remove(@PathVariable Long[] iflightOrderInvoiceIds)
    {
        return toAjax(iflightOrderInvoiceService.deleteIflightOrderInvoiceByIds(iflightOrderInvoiceIds));
    }
}
